<!DOCTYPE html>
<html lang="en">
<head>
    <title>通用罚没</title>
    <#include "../inc/header.ftl"/>
</head>

<body class="no-skin">

<div class="main-container ace-save-state" id="main-container">

    <div class="main-content">
        <div class="main-content-inner">

            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">
                        <table id="MainGrid"></table>
                        <div id="toolbar">
                            <div style="padding:8px">
                                单据号：<input id="billnum" class="easyui-textbox"
                                           style="width:140px">&emsp;
                                付款账户：<input id="accountcodefind" name="accountcodefind">&emsp;
                                收款时间：<input id="paybankdt" class="easyui-datebox" style="width:140px">&emsp;
                                <a href="#" onclick="javascript:searchInfo()" class="easyui-linkbutton"
                                   iconCls="icon-search">查 询</a>
                            </div>
                            <div style="padding:8px 8px 4px">
                                <a href="#" class="easyui-linkbutton" iconCls="icon-edit"
                                   onclick="javascript:editInfo()">详情</a>
                                <a href="#" class="easyui-linkbutton" iconCls="icon-redo"
                                   onclick="javascript:sendInfo(1)">发送</a>
                                <a href="#" class="easyui-linkbutton" iconCls="icon-back"
                                   onclick="javascript:sendInfo(2)">冲销</a>
                                <a href="#" class="easyui-linkbutton" iconCls="icon-print"
                                   onclick="javascript:exportInfo()">导出</a>
                            </div>
                        </div>
                    </div>
                </div><!-- /.row -->
            </div><!-- /.page-content -->
            <#--修改弹框-->
            <div id="box-update" class="ui-dialog-content hide" data-options="minimizable:true,maximizable:true">
                <form class="form-horizontal" id="form-update" method="post" file="true">
                    <div class="form-group">罚没信息单据</div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">处罚决定书id</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="punishinfoid" id="punishinfoid"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>

                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">处罚决定书号</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="punishbillnum" id="punishbillnum"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>

                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">区划</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="cantonname" id="cantonname"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">单位</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="unitname" id="unitname"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">票据年度</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="billyear" id="billyear"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">政策文件</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="policyfiles" id="policyfiles"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">文号</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="policynumber" id="policynumber"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">主体机关代码</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="suborg" id="suborg"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">罚缴分离代码</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="childorg" id="childorg"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">当事人</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="penaltyobjects" id="penaltyobjects"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">违法地址</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="address" id="address"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">违法行为</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="illegal" id="illegal" class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">政策规定</label>

                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="regulations" id="regulations"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="editable:false"/>
                            </div>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">法律依据&nbsp;</label>
                        <div class="col-xs-12 col-sm-3">
                                  <span class="block input-icon input-icon-right">
                                      <input type="text" name="punishbasis" id="punishbasis"
                                             class="col-xs-12 easyui-validatebox"
                                             data-options="readonly:true "/>
                                  </span>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">处罚决定</label>
                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="punishdecision" id="punishdecision"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">处罚金额</label>
                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="punishamt" id="punishamt"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">滞纳金</label>
                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="latefee" id="latefee"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">处罚日期</label>
                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="punishdate" id="punishdate"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">代录日期</label>
                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="recorddate" id="recorddate"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">是否减免滞纳金</label>
                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="isremission" id="isremission"
                                       class="col-xs-12 easyui-numberbox"
                                       data-options="readonly:true" style="width: 100%;"/>
                            </div>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">收款户名</label>
                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="accountname" id="accountname"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">收款银行账户</label>
                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="accountcode" id="accountcode"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                        <label class="control-label col-xs-12 col-sm-1 no-padding-right">收款银行开户行</label>
                        <div class="col-xs-12 col-sm-3">
                            <div class="clearfix">
                                <input type="text" name="latefee" id="latefee"
                                       class="col-xs-12 easyui-validatebox"
                                       data-options="readonly:true"/>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <#--修改-->
            <div id="SendBox-add" class="ui-dialog-content hide">
                <div style="padding:8px">
                    复核用户编码：<input id="usercode" class="easyui-textbox" style="width:140px" data-options="required:true">&emsp;
                    复核用户密码：<input id="userpwd" class="easyui-textbox" style="width:140px" data-options="required:true">&emsp;
                    <input id="biaoshi" hidden>&emsp;
                    <a href="#" class="easyui-linkbutton" iconCls="icon-redo" onclick="javascript:pageSendInfo()"><span
                                id="sendClean"></span></a>
                    <a href="#" class="easyui-linkbutton" iconCls="icon-back" onclick="javascript:cancelInfo()"><span
                                id="sendCleanCan"></span></a>
                </div>
                <table id="SendMainGrid"></table>
            </div>

        </div>
    </div><!-- /.main-content -->
</div><!-- /.main-container -->

<!-- basic scripts -->
<#include "../inc/basicjs.ftl"/>

<!-- inline scripts related to this page -->
<script type="text/javascript">
    jQuery(function ($) {
        listPage();
    });

    function searchInfo() {
        listPage(prefix + '/bill/punish/findPunishPage', 1)
    }

    function listPage(url) {
        var billnum = $('#billnum').val();
        var accountcode = $('#accountcodefind').val();
        var paybankdt = $('#paybankdt').val();
        $('#MainGrid').datagrid({
            //title:'化解专户列表',
            url: url,
            checkbox: true,
            pagination: true,
            fitColumns: false,
            striped: true,
            singleSelect: false,
            loadMsg: "正在努力加载数据，请稍后...",
            idField: 'billnum',
            queryParams: {punishbillnum: billnum, accountcode: accountcode, recorddate: paybankdt},
            columns: [[
                {field: 'ck', checkbox: true},
                {title: '处罚决定书id', field: 'punishinfoid', width: 100},
                {title: '处罚决定书号', field: 'punishbillnum', width: 100},
                {title: '区划', field: 'cantonname', width: 110},
                {title: '单位', field: 'unitname', width: 100},
                {title: '票据年度', field: 'billyear', width: 110},
                {title: '政策文件', field: 'policyfiles', width: 100},
                {title: '文号', field: 'policynumber', width: 100},
                {title: '主体机关代码', field: 'suborg', width: 110},
                {title: '罚缴分离代码', field: 'childorg', width: 110},
                {title: '当事人', field: 'penaltyobjects', width: 100},
                {title: '违法地址', field: 'address', width: 100},
                {title: '违法行为', field: 'illegal', width: 100},
                {title: '政策规定', field: 'regulations', width: 100},
                {title: '法律依据', field: 'punishbasis', width: 100},
                {title: '处罚决定', field: 'punishdecision', width: 100},
                {title: '处罚金额', field: 'punishamt', width: 100},
                {title: '滞纳金', field: 'latefee', width: 110},
                {title: '处罚日期', field: 'punishdate', width: 100},
                {title: '代录日期', field: 'recorddate', width: 100},
                {title: '是否减免滞纳金', field: 'isremission', width: 100},
                {title: '收款户名', field: 'accountname', width: 100},
                {title: '收款银行账号', field: 'accountcode', width: 100},
                {title: '收款银行开户行', field: 'bankname', width: 100}
            ]],
            toolbar: '#toolbar'
        });
        $(window).resize(function () {
            $('#MainGrid').datagrid('resize');
        });
    }

    /*根据id查询专户详细信息*/
    $('#MainGrid').datagrid({
        onDblClickCell: function(index){
            $("#MainGrid").datagrid("selectRow",index);
            editInfo();
        }
    });
    function editInfo() {
        var rows = $('#MainGrid').datagrid('getSelections');
        console.log(rows);
        if (rows.length == 0) {
            $.messager.alert('提示', '请选择要编辑的数据', 'info');
            return;
        }
        if (rows.length>1) {
            $.messager.alert('提示', '修改操作不能多选', 'info');
            return;
        }

        $('#form-update').form('load',rows[0]);
        showForm();
    }

    function showForm() {
        $("#MainGrid").datagrid("clearChecked");
        $("#box-update").removeClass('hide').dialog({
            title: '&nbsp;详情',
            iconCls: 'icon-save',
            width: 800,
            height: 500,
            modal: true,
            buttons: [{
                text: '关闭',
                iconCls: 'icon-cancel',
                width: 80,
                plain: false,
                handler: function () {
                    $('#box-update').dialog('close')
                }
            }]
        });
    }

    //收款网点下拉框
    $('#bankstationname').combobox({
        url: prefix + '/base/basedata/findBankStation',
        valueField: 'bankstationname',
        textField: 'bankstationname'
    });

    function sendInfo(opt) {


        $('#biaoshi').val(opt);
        var tit = (opt == 1) ? '发送' : '冲销';
        if (opt == 1) {
            $('#sendClean').text('确认发送');
            $('#sendCleanCan').text('取消发送');
        } else {
            $('#sendClean').text('确认冲销');
            $('#sendCleanCan').text('取消冲销');
        }
        var row = $('#MainGrid').datagrid('getSelections');
        if (row.length == 0) {
            $.messager.alert('提示', '请选择要发送的数据', 'info');
            return;
        }
        console.log(row);
        $("#SendBox-add").removeClass('hide').dialog({
            title: '&nbsp;' + tit,
            iconCls: 'icon-add',
            width: 600,
            height: 500,
            modal: true,
            buttons: [{
                text: '取消',
                iconCls: 'icon-cancel',
                width: 80,
                plain: false,
                handler: function () {
                    $('#SendBox-add').dialog('close')
                }
            }]
        });


        var list = [];
        $.each(row, function (index, value) {
            list.push(value.punishinfoid)
        });
        // 右侧表格
        $('#SendMainGrid').datagrid({
            data: row,
            fitColumns: false,
            striped: true,
            singleSelect: false,
            modal: true,
            loadMsg: "正在加载数据，请稍后...",
            columns: [[
                {title: '处罚决定书id', field: 'punishinfoid', width: 100},
                {title: '处罚决定书号', field: 'punishbillnum', width: 100},
                {title: '区划', field: 'cantonname', width: 110},
                {title: '单位', field: 'unitname', width: 100},
                {title: '票据年度', field: 'billyear', width: 110},
                {title: '政策文件', field: 'policyfiles', width: 100},
                {title: '文号', field: 'policynumber', width: 100},
                {title: '主体机关代码', field: 'suborg', width: 110},
                {title: '罚缴分离代码', field: 'childorg', width: 110},
                {title: '当事人', field: 'penaltyobjects', width: 100},
                {title: '违法地址', field: 'address', width: 100},
                {title: '违法行为', field: 'illegal', width: 100},
                {title: '政策规定', field: 'regulations', width: 100},
                {title: '法律依据', field: 'punishbasis', width: 100},
                {title: '处罚决定', field: 'punishdecision', width: 100},
                {title: '处罚金额', field: 'punishamt', width: 100},
                {title: '滞纳金', field: 'latefee', width: 110},
                {title: '处罚日期', field: 'punishdate', width: 100},
                {title: '代录日期', field: 'recorddate', width: 100},
                {title: '是否减免滞纳金', field: 'isremission', width: 100},
                {title: '收款户名', field: 'accountname', width: 100},
                {title: '收款银行账号', field: 'accountcode', width: 100},
                {title: '收款银行开户行', field: 'bankname', width: 100}
            ]],
        });
    }
    //  ----------------确认发送
    function pageSendInfo() {
        var usercode = $('#usercode').val();
        var userpwd = $('#userpwd').val();
        if(usercode==null||usercode==''){
            $.messager.alert('提示', '请输入用户编码', 'info');
            return;
        }
        if(userpwd==null||userpwd==''){
            $.messager.alert('提示', '请输入用户密码', 'info');
            return;
        }
        var row = $('#SendMainGrid').datagrid('getData');
        var list = [];
        $.each(row.rows,function(index, value) {
            list.push(value.punishinfoid)
        });

        var opt = $('#biaoshi').val();
        console.log(list.toString());
        var url = (opt == 1) ? '/bill/punish/sendPunish' : '/bill/punish/cleanPunish';
        var billids = [];
        $.ajax({
            url: prefix +url,
            type: 'POST',
            data: {
                usercode: usercode,
                userpwd:userpwd,
                billids:list.toString()
            },
            dataType: 'json',
            success:function(data){
                $.messager.alert('提示', data.msg, 'info');
            }
        });
    }
    // 导出
    function exportInfo() {
        var row = $('#MainGrid').datagrid('getSelections');
        var billids = [];
        $.each(row,function(index, value) {
            billids.push(value.punishinfoid)
        });
        var accountcode = $('#accountcodefind').val();
        if(accountcode==null||accountcode==''){
            $.messager.alert('提示', '请选择账户', 'info');
            return;
        }
        if(row == '' || row.length <1){
            $.messager.alert('提示', '请选择要导出的数据', 'info');
            return;
        }
        var downurl = prefix + '/bill/punish/punishExport?1=1';

        accountcode == "" ? downurl = downurl : downurl = downurl + "&accountcode=" + accountcode;
        billids == "" ? downurl = downurl : downurl = downurl + "&billids=" + billids;
        window.location.href = downurl;
    }


    function cancelInfo() {
        $('#SendBox-add').dialog('close')
    }

    $('#accountcodefind').combogrid({
        panelWidth: 550,
        idField: 'accountcode',
        textField: 'accountcode',
        url: prefix + '/base/basedata/findBank',
        columns: [[
            {field: 'ck', checkbox: true},
            {field: 'cantonname', title: '区划', width: 80},
            {field: 'accountcode', title: '账号', width: 160},
            {field: 'bankname', title: '开户行名称', width: 260}
        ]]
    });


</script>
</body>
</html>
